package com.dwxt.community.admin.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.community.admin.service.IntegralServiceAdmin;
import com.dwxt.community.admin.service.OfflineActivityServiceAdmin;
import com.dwxt.community.entity.IntegralRecord;
import com.dwxt.community.entity.OfflineActivity;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.management.counter.perf.PerfInstrumentation;

import java.util.List;

@RestController
@RequestMapping("/cms/offlineActivity")
public class OfflineActivityControllerAdmin {

    @Autowired
    private OfflineActivityServiceAdmin offlineActivityServiceAdmin;

    @Autowired
    private IntegralServiceAdmin integralServiceAdmin;

    @RequestMapping("/selectPage")
    public BaseResult selectPage(Integer pageNum, Integer pageSize) {
        PageInfo<OfflineActivity> offlineActivityPageInfo = offlineActivityServiceAdmin.selectPage(pageNum, pageSize);
        return BaseResult.ok(offlineActivityPageInfo);
    }


    @RequestMapping("/createOrUpdateActivity")
    public BaseResult createOrUpdateActivity(OfflineActivity offlineActivity){
        offlineActivityServiceAdmin.createOrUpdateActivity(offlineActivity);
        return BaseResult.ok();
    }

    @RequestMapping("/delete")
    public BaseResult delete(Integer id){
        offlineActivityServiceAdmin.delete(id);
        return BaseResult.ok();
    }

    //查询线上活动积分记录，现在只有注册和完善个人信息
    @RequestMapping("/selectLineActivityRecord")
    public BaseResult selectLineActivityRecord(Integer pageNum, Integer pageSize) {
        List<OfflineActivity> integralRecordList = integralServiceAdmin.selectLineActivityRecord();
        return BaseResult.ok(integralRecordList);
    }
}
